package com.shu.bolt;

import java.util.Arrays;
import java.util.List;

import org.apache.storm.topology.BasicOutputCollector;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseBasicBolt;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.Values;

public class SplitWordBolt extends BaseBasicBolt {
	 
	public void declareOutputFields(OutputFieldsDeclarer declarer) {
		 declarer.declare(new Fields("word"));
	}

	public void execute(Tuple input, BasicOutputCollector collector) {
		String sentence = input.getString(1); // 一次处理一行\
		System.out.println("---------------------------------accept data:"+sentence);
		String[] split = sentence.split("\\ ");
		List<String> list = Arrays.asList(split);
		collector.emit(new Values(list));
	}


}
